function CInterface(){
    var _oAudioToggle;
    var _oButExit;
    var _oButHelp;
    var _oButRestart;
    var _oHelpPanel=null;
    var _oTimeText;
    var _oTimeDisplay;
    var _oTimeNum;
    var _oScoreDisplay;
    var _oScoreText;
    var _oScoreNum;
    
    var _pStartPosExit;
    var _pStartPosAudio;
    var _pStartPosHelp;
    var _pStartPosRestart;
    
    this._init = function(){                
        var oExitX;
        
        
        var oSprite = s_oSpriteLibrary.getSprite('but_exit');
        _pStartPosExit = {x: CANVAS_WIDTH - (oSprite.height/2)- 10, y: (oSprite.height/2) + 74};
        _oButExit = new CGfxButton(_pStartPosExit.x,_pStartPosExit.y,oSprite,true);
        _oButExit.addEventListener(ON_MOUSE_UP, this._onExit, this);
        
        oExitX = CANVAS_WIDTH - (oSprite.width/2) - 80;
        
        if(DISABLE_SOUND_MOBILE === false || s_bMobile === false){
            var oSprite = s_oSpriteLibrary.getSprite('audio_icon');
            _pStartPosAudio = {x: oExitX, y: (oSprite.height/2) + 74};
            _oAudioToggle = new CToggle(_pStartPosAudio.x,_pStartPosAudio.y,oSprite,s_bAudioActive);
            _oAudioToggle.addEventListener(ON_MOUSE_UP, this._onAudioToggle, this);          
        }

        oExitX = oExitX-68;
        
        var oSprite = s_oSpriteLibrary.getSprite('but_help');
        _pStartPosHelp = {x: oExitX, y: (oSprite.height/2) + 74};
        _oButHelp = new CGfxButton(_pStartPosHelp.x,_pStartPosHelp.y,oSprite,true);
        _oButHelp.addEventListener(ON_MOUSE_UP, this._onButHelpRelease, this);
        _oButHelp.setVisible(false);
        
        oExitX = oExitX-68;
        
        var oSprite = s_oSpriteLibrary.getSprite('but_restart');
        _pStartPosRestart = {x: oExitX, y: (oSprite.height/2) + 74};
        _oButRestart = new CGfxButton(_pStartPosRestart.x,_pStartPosRestart.y,oSprite,true);
        _oButRestart.addEventListener(ON_MOUSE_UP, this._onButRestartRelease, this);
        
        _oTimeText = new createjs.Text(TEXT_TIME,"bold 24px "+PRIMARY_FONT, "#ffffff");
        _oTimeText.x = 262;
        _oTimeText.y = 119;
        _oTimeText.textAlign = "left";
        _oTimeText.textBaseline = "alphabetic";
        _oTimeText.lineWidth = 200;
        s_oStage.addChild(_oTimeText);
        
        var oSprite = s_oSpriteLibrary.getSprite('time_display');
        _oTimeDisplay = createBitmap(oSprite);
        _oTimeDisplay.scaleX=1.4;
        _oTimeDisplay.x = 332;
        _oTimeDisplay.y = 89;       
        s_oStage.addChild(_oTimeDisplay);
        
        _oTimeNum = new createjs.Text("00:00","bold 24px "+PRIMARY_FONT, "#ffffff");
        _oTimeNum.x = 407;
        _oTimeNum.y = 119;
        _oTimeNum.textAlign = "right";
        _oTimeNum.textBaseline = "alphabetic";
        _oTimeNum.lineWidth = 200;
        s_oStage.addChild(_oTimeNum);
        
        _oScoreText = new createjs.Text(TEXT_SCORE,"bold 24px "+PRIMARY_FONT, "#ffffff");
        _oScoreText.x = 434;
        _oScoreText.y = 119;
        _oScoreText.textAlign = "left";
        _oScoreText.textBaseline = "alphabetic";
        _oScoreText.lineWidth = 200;
        s_oStage.addChild(_oScoreText);
        
        var oSprite = s_oSpriteLibrary.getSprite('score_display');
        _oScoreDisplay = createBitmap(oSprite);
        _oScoreDisplay.x = 522;
        _oScoreDisplay.y = 89;       
        s_oStage.addChild(_oScoreDisplay);
        
        _oScoreNum = new createjs.Text("0","bold 24px "+PRIMARY_FONT, "#ffffff");
        _oScoreNum.x = 595;
        _oScoreNum.y = 119;
        _oScoreNum.textAlign = "right";
        _oScoreNum.textBaseline = "alphabetic";
        _oScoreNum.lineWidth = 200;
        s_oStage.addChild(_oScoreNum);
        
        this.refreshButtonPos(s_iOffsetX, s_iOffsetY);
    };
    
    this.refreshButtonPos = function(iNewX,iNewY){

        _oButExit.setPosition(_pStartPosExit.x - iNewX,_pStartPosExit.y);
        _oButHelp.setPosition(_pStartPosHelp.x - iNewX,_pStartPosHelp.y);
        _oButRestart.setPosition(_pStartPosRestart.x - iNewX,_pStartPosRestart.y);        
        if(DISABLE_SOUND_MOBILE === false || s_bMobile === false){
            _oAudioToggle.setPosition(_pStartPosAudio.x - iNewX,_pStartPosAudio.y);
        }
       
    };
    
    this.unload = function(){
        if(DISABLE_SOUND_MOBILE === false || s_bMobile === false){
            _oAudioToggle.unload();
            _oAudioToggle = null;
        }
        
        _oButExit.unload();
        _oButHelp.unload();
        _oButRestart.unload();
        if(_oHelpPanel!==null){
            _oHelpPanel.unload();
        }
		
		s_oInterface = null;
    };

    this.refreshScore = function(iValue){
        _oScoreNum.text = iValue;
    };

    this.refreshTime = function(iValue){
        _oTimeNum.text = iValue;
    };

    this.setVisibleButHelp = function(){
        _oButHelp.setVisible(true);
    };

    this._onButHelpRelease = function(){
        _oHelpPanel = new CHelpPanel();
    };
    
    this._onButRestartRelease = function(){
        s_oGame.restartGame();
        $(s_oMain).trigger("restart_level", 1);
        $(s_oMain).trigger("show_interlevel_ad");
    };
    
    this.onExitFromHelp = function(){
        _oHelpPanel.unload();
    };
    
    this._onAudioToggle = function(){
        createjs.Sound.setMute(s_bAudioActive);
        s_bAudioActive = !s_bAudioActive;
    };
    
    this._onExit = function(){
      s_oGame.onExit();
      $(s_oMain).trigger("end_level", 1);
      $(s_oMain).trigger("end_session");
      $(s_oMain).trigger("show_interlevel_ad");
    };
    
    s_oInterface = this;
    this._init();
    
	
    return this;
}

var s_oInterface = null;
